package ezy.widget.pullrefresh;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract class PullBase implements IPullIndicator {

    private View _root;
    private PullRefreshList.State _state = PullRefreshList.State.NONE;


    public <T extends View> T findViewById(int resId) {
        return (T)_root.findViewById(resId);
    }

    protected View inflate(ViewGroup parent, int resId) {
         _root = LayoutInflater.from(parent.getContext()).inflate(resId, parent, false);

        return _root;
    }


    public View getView() {
        return _root;
    }

    @Override
    public boolean isHide() {
        return false;
    }

    @Override
    public int getPullHeight() {
        return 0;
    }

    @Override
    public void onState(PullRefreshList.State state) {
        if (this._state == state) {
            return;
        }
        onStateChanged(state, _state);
        _state = state;
    }

    @Override
    public void onPulling(float scale) {

    }

    protected void onStateChanged(PullRefreshList.State state, PullRefreshList.State old) {
        switch (state) {
        case NORMAL:
            break;
        case READY:
            break;
        case PULLING:
            break;
        case LOADING:
        default:
            break;
        }
    }
}
